package com.hebeu.xwl.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.hebeu.xwl.pojo.Article;
import com.hebeu.xwl.vo.PageVo;
import com.hebeu.xwl.vo.SearchVo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public interface ArticleService extends IService<Article> {

    void createTable(String index);

    void addArticle(Article article, String index);

    //找不到合适的方式修，只能先注释掉
    //@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = {Exception.class})
    List<Article> findAll(String index, int userId);
    //找不到合适的方式修，只能先注释掉
    //@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = {Exception.class})
    void addArticleList(List<Article> articleList, String index, int userId);

    //@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = {Exception.class})
    void overwrite(List<Article> articleList, String index, int userId);

    //@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = true)
    int findArticleNum(String index);

    PageVo<Article> pageFind(String index, int userId, int page);

    public String countByPubdate(int userId,int batchId);

    public String countByPubdateAndAuthor(int userId,int batchId,String author);

    public String keywordsCount(int userId,int batchId);

    public String keywordsCountByAuthor(int userId,int batchId,String author);

    public String sumLikesByAuthor(int userId,int batchId);

    public String sumViewsByAuthor(int userId,int batchId);

    public String sumCommentaryByAuthor(int userId,int batchId);

    public List<Article> findArticleByPubdate(int userId,int batchId,String pubdate);

    public List<Article> findArticleByPubdateAndAuthor(
            int userId,int batchId,String pubdate,String author);

    public List<Article> findArticleByAuthor(int userId,int batchId,String author);

    public List<Article> findArticleByKeywords(int userId,int batchId,String keywords);

    public List<Article> findArticleByKeywordsAndAuthor(
            int userId,int batchId,String keywords,String author);

    public List<Article> findArticleBySearchVo(int userId, int batchId, SearchVo searchVo);
}
